import { createRouter, createWebHashHistory, type RouteRecordRaw } from 'vue-router'
import LoginView from '../views/login/LoginView.vue'
import LayoutView from '../views/layout/IndexView.vue'

const routes: RouteRecordRaw[] = [
  {
    path: '/',
    redirect: '/layout',
  },
  {
    path: '/login',
    component: LoginView,
    meta: {
      title: '登录',
    },
  },
  {
    path: '/layout',
    component: LayoutView,
    meta: {
      title: '首页',
    },
    children: [
      {
        path: '/user',
        redirect: '/user/user',
        meta: {
          title: '用户管理',
        },
        children: [
          {
            path: 'user',
            component: () => import('@/views/user/userView.vue'),
            meta: {
              title: '会员管理',
            },
          },
          {
            path: 'address',
            component: () => import('@/views/user/addressView.vue'),
            meta: {
              title: '收货地址',
            },
          },
        ],
      },
    ],
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
